<script type="text/javascript" language="javascript">
    <!--
    var backUrl = window.location.href;
    function onSuccessLogin(oMessage)
    {
        if(oMessage == "ok")
        {

            //var backUrl = window.location;
            if(backUrl.indexOf("detail") >= 0)
               window.location='<?php echo "http://".$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];?>';    //"http://".$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]
            else
            {
                $("#spanLogin").css("display","none");
                $("#sLogin").css("display","block");
                 $("#sUserName").html($("#txtUserId").val());
                $("#txtPwd").val("");
                $("#txtUserId").val("");
            }
        }
        else
            alert("您输入的帐号或者密码有误。");
        $("#btnSubmit").attr("disabled",false);
    }

    function onErrorLogin(x, e)
    {
        alert(x.responseText);
        $("#btnSubmit").attr("disabled",false);
    }

    function onLoginClick()
    {
        if($.trim($("#txtUserId").val()) == "")
        {
	        alert("请输入登录帐号！");
	        $("#txtUserId").focus();
		    return ;
	    }
	    if($.trim($("#txtPwd").val()) == "")
	    {
	        alert("请输入登录密码！");
	        $("#txtPwd").focus();
		    return ;
	    }
        var random = Math.random();
        $.ajax({url:"<?php echo url_for("other/jQuery");?>",data:"random=" + random +"&submitflag=login&userName=" + $("#txtUserId").val() + "&pwd=" + $.md5($("#txtPwd").val()) ,success: onSuccessLogin,error:onErrorLogin})
	    $("#btnSubmit").attr("disabled",true);
    }

    function onLogoutClick()
    {
        var random = Math.random();
        url = '<?php echo "http://".$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];?>'
        $.ajax({url:"<?php echo url_for("other/jQuery");?>",data:"random=" + random +"&submitflag=logout&url=<?php echo $_SERVER["REQUEST_URI"];?>" ,success: function(oMessage){if(oMessage != "ok" && oMessage != "returnUrl") alert(oMessage); else { if(oMessage == "ok") {$("#fLogin").css("display","block");$("#sLogin").css("display","none");}else{ if(backUrl.indexOf("detail") >= 0) window.location= url; else window.location="<?php echo url_for("general/index")?>";}}},error:onErrorLogin})
    }
    //-->
</script>
<div class="login_r" >
     <span id="spanLogin">
         用户名：<input type="text" class="ipt1" id="txtUserId"  name="username" > 密码：<input type="password" class="ipt1" name="password" id="txtPwd" >&nbsp;&nbsp;<input type="submit"  value="登&nbsp;录" id="btnSubmit" name="logsumbit" class="btn2" onclick="onLoginClick()"> <input class="btn2" name="login" type="button" onClick='javascript:window.location="<?php echo url_for("user/register"); ?>";' value="注&nbsp;册" /><!--&nbsp;&nbsp;--><?php //echo link_to("忘记密码","user/getpassword"); ?>&nbsp;<a class="save" href="#">SAVE IT</a>
         </span><span id='sLogin' style="display:none;"> 欢迎回来！<span style="color:#E60180" id="sUserName"></span> <?php echo link_to("我的ieasy","user/home","style=\"text-decoration:underline\"") ?> <a style="text-decoration:underline" href="javascript:onLogoutClick();">退出</a></span>
     <?php
            if($sf_user->getAttribute("userId") != null)
                 echo "<script type=\"text/javascript\"  language=\"javascript\">$('#spanLogin').css('display','none');$('#sLogin').css('display','block');$(\"#sUserName\").html(\"".$sf_user->getAttribute("userName")."\");</script>";
    ?>
</div>